package com.Shop.Center.service;

import com.Shop.Center.entity.Items;
import com.Shop.Center.mapper.ItemsMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ItemsService {
    @Autowired
    ItemsMapper itemsMapper;
    public List get(String type){
        QueryWrapper<Items> queryWrapper=new QueryWrapper<>();
        if(type.equals("all")){
            queryWrapper=null;
        }else{
            queryWrapper.eq("type",type);
        }
        return itemsMapper.selectList(queryWrapper);
    }
    public List search(String name){
        QueryWrapper<Items> queryWrapper=new QueryWrapper<>();
        queryWrapper.like("name",name);
        return itemsMapper.selectList(queryWrapper);
    }
}
